# -*- coding: utf-8 -*-            
# @Author : lidong1227
# @Time : 2023/4/30 20:25
from abc import ABCMeta, abstractmethod

# ---------抽象产品------------
class Shell(metaclass=ABCMeta):
    @abstractmethod
    def show_shell(self):
        pass
class CPU(metaclass=ABCMeta):
    @abstractmethod
    def show_cpu(self):
        pass

class OS(metaclass=ABCMeta):
    @abstractmethod
    def show_os(self):
        pass


# ---------抽象工厂------------
class PhoneFactory(metaclass=ABCMeta):
    @abstractmethod
    def make_shell(self):
        pass

    @abstractmethod
    def make_cpu(self):
        pass

    @abstractmethod
    def make_os(self):
        pass
# ---------具体产品------------
class SmallShell(Shell):
    def show_shell(self):
        print("小手机壳")

class BigShell(Shell):
    def show_shell(self):
        print("大手机壳")

class AppleShell(Shell):
    def show_shell(self):
        print("苹果机壳")


class SnapdragonCPU(CPU):
    def show_cpu(self, is_pro=False):
        if is_pro:
            print("骁龙CPU满血版本")
        else:
            print("骁龙CPU残血版本")

class MediaTek(CPU):
    def show_cpu(self):
        print("联发科CPU")

class AppleCPU(CPU):
    def show_cpu(self):
        print("苹果CPU")

class Android(OS):
    def show_os(self):
        print("安卓系统")

class IOS(OS):
    def show_os(self):
        print("苹果系统")
# ---------具体工厂 ------------

class XiaoMiFactory(PhoneFactory):

    def make_shell(self):
        return SmallShell()

    def make_cpu(self):
        return SnapdragonCPU()

    def make_os(self):
        return Android()


class AppleFactory(PhoneFactory):

    def make_shell(self):
        return AppleShell()

    def make_cpu(self):
        return AppleCPU()

    def make_os(self):
        return IOS()

# ---------客户端------------
class Phone:
    def __init__(self, shell, cpu, os):
        self.shell = shell
        self.cpu = cpu
        self.os = os
    def show_info(self):
        print("手机信息")
        self.cpu.show_cpu()
        self.shell.show_shell()
        self.os.show_os()


def make_phone(factory):
    cpu = factory.make_cpu()
    os = factory.make_os()
    shell = factory.make_shell()
    return Phone(shell, cpu, os)

p1 = make_phone(AppleFactory())
p1.show_info()